package com.wgz.flag.mapper;

import com.wgz.flag.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface UserMapper {

    List<User> findAll(User user);

    @Select("SELECT * FROM user WHERE username = #{username}")
    List<User> findByUsername(String username);

    @Select("INSERT INTO user(username, password, email, phone, age) VALUES(#{username}, #{password}, #{email}, #{phone}, #{age})")
    void insert(User user);

    @Select("SELECT * FROM user")
    List<User> getAll();

    User selectById(Long id);

    @Update("update user set username=#{username}, password=#{password}, nickname=#{nickname},  email=#{email}, phone=#{phone}, avatar=#{avatar}, age=#{age} where id = #{id}")
    void updateById(User user1);
}